-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support logging into a registry if necessary #787
Support logging into a registry if necessary #787
Conversation
1155a56
to
fc636da
Compare
Build succeeded.
|
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in. The parsing process is quite fragile since Podman does not provide clear means to distinguish such cases and provided messages differ between registries. This should distinguish authorization errors with registry.redhat.io and docker.io. Testing of this feature is tricky as it relies on network which is inherently flaky. So, not everything added/changed by this will be tested. In the future we'll have to start mocking servers to be able to do so. containers#787
fc636da
to
6808d35
Compare
Build failed.
|
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in. The parsing process is quite fragile since Podman does not provide clear means to distinguish such cases and provided messages differ between registries. This should distinguish authorization errors with registry.redhat.io and docker.io. Testing of this feature is tricky as it relies on network which is inherently flaky. So, not everything added/changed by this will be tested. In the future we'll have to start mocking servers to be able to do so. containers#787
6808d35
to
bbcd5e1
Compare
Build failed.
|
recheck |
Build failed.
|
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in. The parsing process is quite fragile since Podman does not provide clear means to distinguish such cases and provided messages differ between registries. This should distinguish authorization errors with registry.redhat.io and docker.io. Testing of this feature is tricky as it relies on network which is inherently flaky. So, not everything added/changed by this will be tested. In the future we'll have to start mocking servers to be able to do so. containers#787
bbcd5e1
to
4ab6577
Compare
Build succeeded.
|
I may have gotten an idea on how to test this reliably. Until I have it figured out or I give up, let's postpone merging this. EDIT: I also found more info regarding the parsed error messages. I started to make more sense of them :). All thanks to reading the documentation \o/. |
src/pkg/podman/podman.go
Outdated
return nil | ||
} | ||
|
||
// Pull pulls an image. Wraps around command 'podman pull'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra pulls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is intentional since Go tooling requires function comments to start with the name of the function. But I'd reword the function anyway :).
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in or tell the user that the requested image/manifest does not exist. The parsing process relies on error messages that match the OCI specification[0]. Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a flag --namespace is used in Podman during their creation. [0] https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes containers#787
4ab6577
to
b160671
Compare
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in or tell the user that the requested image/manifest does not exist. The parsing process relies on error messages that match the OCI specification[0]. Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a flag --namespace is used in Podman during their creation. [0] https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes containers#787
b160671
to
b88cc96
Compare
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in or tell the user that the requested image/manifest does not exist. The parsing process relies on error messages that match the OCI specification[0]. Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a flag --namespace is used in Podman during their creation. [0] https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes containers#787
b88cc96
to
12b766c
Compare
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offer the user the means to log in or tell the user that the requested image/manifest does not exist. The parsing process relies on error messages that match the OCI specification[0]. Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a flag --namespace is used in Podman during their creation. [0] https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes containers#787
Build failed.
|
A subsequent commit will use this when retrying the 'podman pull' after logging the user into the registry for images that require authorization. containers#787
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offers the user the means to log in. Some changes by Debarshi Ray. containers#787
Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a different root for Podman is used. The only tested registry implementation is Docker[0]. [0] https://hub.docker.com/_/registry/ containers#787
The new additions to the system tests makes them take longer to run, and was causing them to timeout. containers#787
ce01f2a
to
f160b2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things about the test suite:
(You did a really good job setting up the registries as part of the test suite! Well done.)
load 'libs/helpers' | ||
|
||
@test "test suite: Setup" { | ||
# Cache the default image for the system | ||
_pull_and_cache_distro_image $(get_system_id) $(get_system_version) || die | ||
# Cache all images that will be needed during the tests | ||
_pull_and_cache_distro_image fedora 32 || die | ||
_pull_and_cache_distro_image rhel 8.4 || die |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use a Fedora (or anything that's not UBI) image for testing?
$PODMAN --root "$PODMAN_REG_ROOT" logs docker-registry-auth | ||
|
||
# Add UBI8 to created registries | ||
run $SKOPEO copy "dir:${IMAGE_CACHE_DIR}/fedora-toolbox-32" "docker://localhost:50000/fedora-toolbox:32" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the comment? Is the comment really necessary? We didn't use one for the similar statement below. :)
Build failed.
|
This is meant to get a better understanding of a failed 'podman pull' invocation to understand whether pulling an image requires logging into the registry or not. Currently, 'podman pull' doesn't have a dedicated exit code to denote authorization errors, so this is meant to be a temporary workaround for that. Parsing the error stream is inherently fragile and tricky because there's no guarantee that the structure of the messages won't change, and there's no clear definition of how the messages are laid out. Therefore, this approach can't be treated as a generic solution for getting detailed information about failed Podman invocations. The error stream is used not only for dumping error messages, but also for showing progress bars. Therefore, all lines are skipped until one that starts with "Error: " is found. This is a heuristic based on how Go programs written using the Cobra [1] library tend to report errors. All subsequent lines are taken together and split around the ": " sub-string, on the assumption that the ": " sub-string is used when a new error message is prefixed to an inner error. Each sub-string created from the split is treated as a potential member of the chain of errors reported within Podman. Some real world examples of the 'podman pull' error stream in the case of authorization errors are: * With Docker Hub (https://hub.docker.com/): Trying to pull docker.io/library/foobar:latest... Error: Error initializing source docker://foobar:latest: Error reading manifest latest in docker.io/library/foobar: errors: denied: requested access to the resource is denied unauthorized: authentication required * With registry.redhat.io: Trying to pull registry.redhat.io/foobar:latest... Error: Error initializing source docker://registry.redhat.io/foobar:latest: unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication [1] https://github.com/spf13/cobra/ https://pkg.go.dev/github.com/spf13/cobra containers#689 containers#786 containers#787
This way the standard error stream of the spawned binaries can be inspected to get a better understanding of the failure, while still being shown to the user when run with the '--verbose' flag. Unfortunately, this breaks the progress bar in 'podman pull' because the standard error stream is no longer connected to a file descriptor that's a terminal device. containers#689 containers#787 containers#823
A subsequent commit will use this when retrying the 'podman pull' after logging the user into the registry for images that require authorization. containers#689 containers#787
Some registries contain private repositories of images and require the user to log in first to gain access. With this Toolbox tries to recognize errors when pulling images and offers the user the means to log in. Some changes by Debarshi Ray. containers#689 containers#787
Testing of this feature is tricky as it relies on network which is inherently flaky. So, as part of the setup two local image registries are created and these features can be tested against them. To prevent the removal of the registries during testing a different root for Podman is used. The only tested registry implementation is Docker[0]. [0] https://hub.docker.com/_/registry/ containers#689 containers#787
The new additions to the system tests makes them take longer to run, and was causing them to timeout. containers#689 containers#787
f160b2e
to
ba2fc50
Compare
Build failed.
|
Unless In the absence of a dedicated exit code from First, the messages that get dumped in the error stream don't have any fixed structure or format, and can change from one Podman version to another. Moreover, the error stream is also used to show things like progress bars, so those need to be skipped when parsing it. This makes it very fragile to test whether the parsing works as expected across several Podman versions in several operating systems. Second, since the error stream is also used to show progress bars for So, long story short, we either need |
I'll close this since this approach is not acceptable long-term-wise. If the work is attempted again, it can be done in a separate PR. |
This introduces handling of registries with private repositories/images. Practically speaking, if a used image lives in a registry behind a login wall, Toolbox will be aware of the fact and asks the user if they want to log in. This can be automated by combining the existing global
--assumeyes
option with newly introduced options--authfile
and--creds
in commandcreate
.The authentication is done by Podman and Toolbox only serves as a mediator between the user and Podman. It does not record/store user's credentials in any way.
Examples of the new behaviour:
Depends on #786, #823
Closes #754